Involved Source Filesalerts.goapikeys.goclient.godashboards.godatasources.go Package grabana provides a developer-friendly way of creating Grafana dashboards.
Whether you prefer writing **code or YAML**, if you are looking for a way to
version your dashboards configuration or automate tedious and error-prone
creation of dashboards, this library is meant for you.
builder := dashboard.New(
"Awesome dashboard",
dashboard.VariableAsInterval(
"interval",
interval.Values([]string{"30s", "1m", "5m", "10m", "30m", "1h", "6h", "12h"}),
),
dashboard.VariableAsQuery(
"status",
query.DataSource("prometheus-default"),
query.Request("label_values(prometheus_http_requests_total, code)"),
query.Sort(query.NumericalAsc),
),
dashboard.Row(
"Prometheus",
row.WithTimeSeries(
"HTTP Rate",
timeseries.WithPrometheusTarget(
"rate(promhttp_metric_handler_requests_total[$interval])",
prometheus.Legend("{{handler}} - {{ code }}"),
),
),
row.WithTable(
"Threads",
table.WithPrometheusTarget("go_threads"),
table.HideColumn("Time"),
table.AsTimeSeriesAggregations([]table.Aggregation{
{Label: "AVG", Type: table.AVG},
{Label: "Current", Type: table.Current},
}),
),
row.WithStat(
"Heap Allocations",
stat.Unit("bytes"),
stat.WithPrometheusTarget("go_memstats_heap_alloc_bytes"),
),
),
dashboard.Row(
"Some text, because it might be useful",
row.WithText(
"Some awesome html?",
text.HTML("<b>lalalala</b>"),
),
),
)
For a more information visit https://github.com/K-Phoen/grabanafolders.go
Client represents a Grafana HTTP client. APIKeys lists active API keys. AddAlert creates an alert group within a given namespace. ConfigureAlertManager updates the alert manager configuration. CreateAPIKey creates a new API key. CreateFolder creates a dashboard folder.
See https://grafana.com/docs/grafana/latest/reference/dashboard_folders/ DeleteAPIKeyByName deletes an API key given its name. DeleteAlertGroup deletes an alert group. DeleteDashboard deletes a dashboard given its UID. DeleteDatasource deletes a datasource given its name. FindOrCreateFolder returns the folder by its name or creates it if it doesn't exist. GetDashboardByTitle finds a dashboard, given its title. GetDatasourceUIDByName finds a datasource UID given its name. GetFolderByTitle finds a folder, given its title. UpsertDashboard creates or replaces a dashboard, in the given folder. UpsertDatasource creates or replaces a datasource.
func NewClient(http *http.Client, host string, options ...Option) *Client
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.